﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Roslyn.Compilers.Common;
using Roslyn.Services;

namespace Analysis
{
    public class RoslynHelper : IRoslynHelper
    {
        public Tuple<ITypeSymbol, ISymbol> GetTypeAndSymbol(CommonSyntaxNode node, IDocument doc)
        {
            var model = doc.GetSemanticModel();
            return Tuple.Create(model.GetTypeInfo(node).Type, model.GetSymbolInfo(node).Symbol);
        }

        public IEnumerable<IProject> GetAllProjectsInSolution(IDocument doc)
        {
            return doc.Project.Solution.Projects;
        }

        public IEnumerable<IDocument> GetAllDocumentsInSolution(IDocument doc)
        {
            return GetAllProjectsInSolution(doc).Select(p => p.Documents).SelectMany(d => d);
        }
    }
}
